{include file="public/header" /}
<span class="layui-breadcrumb">
  <a href="{:url('Blog/index')}?nav=blog-bloglist">分类</a>
  <a><cite>编辑-{$one['cname']}</cite></a>
</span>
<style>
    .layui-form-label{width:200px;}
    .layui-form-item .layui-input-block{margin-left:230px;}
    .tox-tinymce-aux {
        z-index: 5000 !important;
    }
    .tox-fullscreen .layui-side-menu{
        z-index: 0 !important;
    }
</style>
<!--<script src="https://cdn.tiny.cloud/1/fuclxmtuqcgjlv66r58qtuu0y433gpi4kf0kbsq34rqcqvlv/tinymce/6/tinymce.min.js" referrerpolicy="origin"></script>-->
<script type="text/javascript" src="/static/tinymce/tinymce.min.js" referrerpolicy="origin"></script>
<div class="layui-fluid">

    <div class="layui-card">
        <form class="layui-form" id="product_form" action="" style='padding:10px'>



            <div class="layui-form-item">
                <label class="layui-form-label">无筛选列表页描述信息</label>
                <div class="layui-input-block">
                    <!--
                    <textarea id="total_des" name="total_des" style="width:100%;">{$classify_content['total_des']}</textarea>-->
                    <textarea id="total_des" name="total_des">{$classify_content['total_des']|raw|default=''}</textarea>
                </div>
            </div>

            <div class="layui-form-item">

                <label class="layui-form-label">筛选列表页描述信息</label>
                <div class="layui-input-block">
                    <textarea id="filter_total_des" name="filter_total_des" style="width:100%;">{$classify_content['filter_total_des']}</textarea>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">表头的斜体字简介</label>
                <div class="layui-input-block">
                    <textarea id="tab_title_des" name="tab_title_des" style="width:100%;height:80px;">{$classify_content['tab_title_des']}</textarea>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">方框内的简介</label>
                <div class="layui-input-block">
                    <textarea id="block_des" name="block_des" style="width:100%;height:80px;">{$classify_content['block_des']}</textarea>
                </div>
            </div>
            <div class="layui-form-item">

                <div class="layui-input-block" style="color: red;">
                    详情页的文字介绍，仅在最小分类页进行设置，若不是最小分类页下面此处不显示
                </div>
            </div>
            <?php
        $min_class=Db::table('lily_classify')->field('id')->where('fid',$one['id'])->find();
            if(empty($min_class)){
            ?>
            <div class="layui-form-item">
                <label class="layui-form-label">详情页介绍</label>
                <div class="layui-input-block">
                    <textarea id="detail_des" name="detail_des" style="width:100%;">{$classify_content['detail_des']}</textarea>
                </div>
            </div>
            <?php } ?>

            <div class="layui-form-item">
                <label class="layui-form-label"></label>
                <div class="layui-input-block">
                    <button type='button' class="layui-btn layui-btn-normal" onclick="tijiao({$one['id']})">确定</button>
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-input-block">
                    页面链接 : <a style="color: #36648a" href="/{:get_class_uplower_url($one['id'])}" target='_blank'>{$one['cname']}</a>
                </div>
            </div>

        </form>
    </div>
</div>
{include file="/public/footer" /}
<script charset="utf-8" src="/static/kindeditor/kindeditor-all.js"></script>
<script charset="utf-8" src="/static/kindeditor/lang/zh-CN.js"></script>
<script>
    tinymce.init({
        selector: '#total_des',
        plugins: 'ai tinycomments mentions anchor autolink charmap codesample emoticons image link lists media searchreplace table visualblocks wordcount checklist mediaembed casechange export formatpainter pageembed permanentpen footnotes advtemplate advtable advcode editimage tableofcontents mergetags powerpaste tinymcespellchecker autocorrect a11ychecker typography inlinecss code image axupimgs preview fullscreen link ',
        toolbar: 'undo redo | blocks fontfamily fontsize | bold italic underline strikethrough | link image media table mergetags | align lineheight | tinycomments | checklist numlist bullist indent outdent | emoticons charmap | removeformat | code axupimgs | fullscreen | link',
        tinycomments_mode: 'embedded',
        tinycomments_author: 'Author name',
        mergetags_list: [
            { value: 'First.Name', title: 'First Name' },
            { value: 'Email', title: 'Email' },
        ],
        language_url: '/static/tinymce/langs/zh-Hans.js', // 中文包的存放路径
        language: 'zh-Hans',
        //language: 'zh_CN',
        allow_html_in_named_anchor: true,
        //images_upload_url: '/index/Oos/tinymce_upload',
        images_upload_base_path: '/index',
        image_title: true,
        file_picker_callback: function (callback, value, meta) {
            //文件分类
            var filetype='.pdf, .txt, .zip, .rar, .7z, .doc, .docx, .xls, .xlsx, .ppt, .pptx, .mp3, .mp4';
            //后端接收上传文件的地址
            var upurl='/index/Oos/tinymce_upload';
            //为不同插件指定文件类型及后端地址
            switch(meta.filetype){
                case 'image':
                    filetype='.jpg, .jpeg, .png, .gif';
                    upurl='/index/Oos/tinymce_upload';
                    break;
                case 'media':
                    filetype='.mp3, .mp4';
                    upurl='/index/Oos/tinymce_upload';
                    break;
                case 'file':
                default:
            }
            //模拟出一个input用于添加本地文件
            var input = document.createElement('input');
            input.setAttribute('type', 'file');
            input.setAttribute('accept', filetype);
            input.click();
            input.onchange = function() {
                var file = this.files[0];

                var xhr, formData;
                console.log(file.name);
                xhr = new XMLHttpRequest();
                xhr.withCredentials = false;
                xhr.open('POST', upurl);
                xhr.onload = function() {
                    var json;
                    if (xhr.status != 200) {
                        failure('HTTP Error: ' + xhr.status);
                        return;
                    }
                    json = JSON.parse(xhr.responseText);
                    if (!json || typeof json.location != 'string') {
                        failure('Invalid JSON: ' + xhr.responseText);
                        return;
                    }
                    callback(json.location);
                };
                formData = new FormData();
                formData.append('file', file, file.name );
                xhr.send(formData);

            };
        },
        setup : function(ed) {
            ed.on("change", function(e){
                $('#total_des').html(tinymce.activeEditor.getContent());
            });
        },

        ai_request: (request, respondWith) => respondWith.string(() => Promise.reject("See docs to implement AI Assistant")),
    });
    tinymce.init({
        selector: '#filter_total_des',
        plugins: 'ai tinycomments mentions anchor autolink charmap codesample emoticons image link lists media searchreplace table visualblocks wordcount checklist mediaembed casechange export formatpainter pageembed permanentpen footnotes advtemplate advtable advcode editimage tableofcontents mergetags powerpaste tinymcespellchecker autocorrect a11ychecker typography inlinecss code image axupimgs preview fullscreen link ',
        toolbar: 'undo redo | blocks fontfamily fontsize | bold italic underline strikethrough | link image media table mergetags | align lineheight | tinycomments | checklist numlist bullist indent outdent | emoticons charmap | removeformat | code axupimgs | fullscreen | link',
        tinycomments_mode: 'embedded',
        tinycomments_author: 'Author name',
        mergetags_list: [
            { value: 'First.Name', title: 'First Name' },
            { value: 'Email', title: 'Email' },
        ],
        language_url: '/static/tinymce/langs/zh-Hans.js', // 中文包的存放路径
        language: 'zh-Hans',
        //language: 'zh_CN',
        allow_html_in_named_anchor: true,
        //images_upload_url: '/index/Oos/tinymce_upload',
        images_upload_base_path: '/index',
        image_title: true,
        file_picker_callback: function (callback, value, meta) {
            //文件分类
            var filetype='.pdf, .txt, .zip, .rar, .7z, .doc, .docx, .xls, .xlsx, .ppt, .pptx, .mp3, .mp4';
            //后端接收上传文件的地址
            var upurl='/index/Oos/tinymce_upload';
            //为不同插件指定文件类型及后端地址
            switch(meta.filetype){
                case 'image':
                    filetype='.jpg, .jpeg, .png, .gif';
                    upurl='/index/Oos/tinymce_upload';
                    break;
                case 'media':
                    filetype='.mp3, .mp4';
                    upurl='/index/Oos/tinymce_upload';
                    break;
                case 'file':
                default:
            }
            //模拟出一个input用于添加本地文件
            var input = document.createElement('input');
            input.setAttribute('type', 'file');
            input.setAttribute('accept', filetype);
            input.click();
            input.onchange = function() {
                var file = this.files[0];

                var xhr, formData;
                console.log(file.name);
                xhr = new XMLHttpRequest();
                xhr.withCredentials = false;
                xhr.open('POST', upurl);
                xhr.onload = function() {
                    var json;
                    if (xhr.status != 200) {
                        failure('HTTP Error: ' + xhr.status);
                        return;
                    }
                    json = JSON.parse(xhr.responseText);
                    if (!json || typeof json.location != 'string') {
                        failure('Invalid JSON: ' + xhr.responseText);
                        return;
                    }
                    callback(json.location);
                };
                formData = new FormData();
                formData.append('file', file, file.name );
                xhr.send(formData);

            };
        },
        setup : function(ed) {
            ed.on("change", function(e){
                $('#filter_total_des').html(tinymce.activeEditor.getContent());
            });
        },

        ai_request: (request, respondWith) => respondWith.string(() => Promise.reject("See docs to implement AI Assistant")),
    });
    tinymce.init({
        selector: '#detail_des',
        plugins: 'ai tinycomments mentions anchor autolink charmap codesample emoticons image link lists media searchreplace table visualblocks wordcount checklist mediaembed casechange export formatpainter pageembed permanentpen footnotes advtemplate advtable advcode editimage tableofcontents mergetags powerpaste tinymcespellchecker autocorrect a11ychecker typography inlinecss code image axupimgs preview fullscreen link ',
        toolbar: 'undo redo | blocks fontfamily fontsize | bold italic underline strikethrough | link image media table mergetags | align lineheight | tinycomments | checklist numlist bullist indent outdent | emoticons charmap | removeformat | code axupimgs | fullscreen | link',
        tinycomments_mode: 'embedded',
        tinycomments_author: 'Author name',
        mergetags_list: [
            { value: 'First.Name', title: 'First Name' },
            { value: 'Email', title: 'Email' },
        ],
        language_url: '/static/tinymce/langs/zh-Hans.js', // 中文包的存放路径
        language: 'zh-Hans',
        //language: 'zh_CN',
        allow_html_in_named_anchor: true,
        //images_upload_url: '/index/Oos/tinymce_upload',
        images_upload_base_path: '/index',
        image_title: true,
        file_picker_callback: function (callback, value, meta) {
            //文件分类
            var filetype='.pdf, .txt, .zip, .rar, .7z, .doc, .docx, .xls, .xlsx, .ppt, .pptx, .mp3, .mp4';
            //后端接收上传文件的地址
            var upurl='/index/Oos/tinymce_upload';
            //为不同插件指定文件类型及后端地址
            switch(meta.filetype){
                case 'image':
                    filetype='.jpg, .jpeg, .png, .gif';
                    upurl='/index/Oos/tinymce_upload';
                    break;
                case 'media':
                    filetype='.mp3, .mp4';
                    upurl='/index/Oos/tinymce_upload';
                    break;
                case 'file':
                default:
            }
            //模拟出一个input用于添加本地文件
            var input = document.createElement('input');
            input.setAttribute('type', 'file');
            input.setAttribute('accept', filetype);
            input.click();
            input.onchange = function() {
                var file = this.files[0];

                var xhr, formData;
                console.log(file.name);
                xhr = new XMLHttpRequest();
                xhr.withCredentials = false;
                xhr.open('POST', upurl);
                xhr.onload = function() {
                    var json;
                    if (xhr.status != 200) {
                        failure('HTTP Error: ' + xhr.status);
                        return;
                    }
                    json = JSON.parse(xhr.responseText);
                    if (!json || typeof json.location != 'string') {
                        failure('Invalid JSON: ' + xhr.responseText);
                        return;
                    }
                    callback(json.location);
                };
                formData = new FormData();
                formData.append('file', file, file.name );
                xhr.send(formData);

            };
        },
        setup : function(ed) {
            ed.on("change", function(e){
                $('#detail_des').html(tinymce.activeEditor.getContent());
            });
        },

        ai_request: (request, respondWith) => respondWith.string(() => Promise.reject("See docs to implement AI Assistant")),
    });
</script>
<script>
    KindEditor.ready(function(K) {
        /*
        window.editor=K.create('#total_des',{'items':['source', '|', 'undo', 'redo', '|','selectall', 'preview', 'print', 'code', 'cut', 'copy', 'paste','plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright','justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript','superscript', 'clearhtml', 'quickformat', '|','formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold','italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|', 'image', 'media', 'insertfile', 'table', 'hr', 'emoticons', 'baidumap', 'pagebreak','anchor', 'link', 'unlink','|', 'fullscreen'],'uploadJson':"{:url('index/Oos/upload_classdes')}",afterCreate : function() { this.sync(); },afterBlur: function(){this.sync();}
        });
        window.editor=K.create('#filter_total_des',{'items':['source', '|', 'undo', 'redo', '|','selectall', 'preview', 'print', 'code', 'cut', 'copy', 'paste','plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright','justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript','superscript', 'clearhtml', 'quickformat', '|','formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold','italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|', 'image', 'media', 'insertfile', 'table', 'hr', 'emoticons', 'baidumap', 'pagebreak','anchor', 'link', 'unlink','|', 'fullscreen'],'uploadJson':"{:url('index/Oos/upload_classdes')}",afterCreate : function() { this.sync(); },afterBlur: function(){this.sync();}
        });
        window.editor=K.create('#detail_des',{'items':['source', '|', 'undo', 'redo', '|','selectall', 'preview', 'print', 'code', 'cut', 'copy', 'paste','plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright','justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript','superscript', 'clearhtml', 'quickformat', '|','formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold','italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|', 'image', 'media', 'insertfile', 'table', 'hr', 'emoticons', 'baidumap', 'pagebreak','anchor', 'link', 'unlink','|', 'fullscreen'],'uploadJson':"{:url('index/Oos/upload_classdes')}",afterCreate : function() { this.sync(); },afterBlur: function(){this.sync();}
        });
         */

    })
    function tijiao(id){
        layer.load();
        var total_des=$.trim($("textarea[name='total_des']").val());
        var filter_total_des=$.trim($("textarea[name='filter_total_des']").val());
        var tab_title_des=$.trim($("textarea[name='tab_title_des']").val());
        var block_des=$.trim($("textarea[name='block_des']").val());
        var detail_des=$.trim($("textarea[name='detail_des']").val());
        if(total_des==''&&filter_total_des==''&&tab_title_des==''&&block_des==''&&detail_des==''){
            layer.closeAll();
            layer.msg('请至少填写一个数据');
            return false;
        }

        $.post("{:url('Classify/enedit')}",{id:id,
            total_des:total_des,
            filter_total_des:filter_total_des,
            tab_title_des:tab_title_des,
            block_des:block_des,
            detail_des:detail_des},function(res){
            if(res.status=='0'){
                layer.closeAll('loading');
                layer.msg(res.msg);
            }
            if(res.status=='1'){
                layer.msg(res.msg,{time: 500 },
                    function(){
                        layer.closeAll();
                        location.href=location.href;
                    });
            }
        })
    }
</script>
